<?php
session_start();

function isLogin() {
  if (isset($_SESSION['login'])) {
    return $_SESSION['login'] == true;
  }
  return false;
}

function isAdmin() {
  if (isLogin()) {
    return $_SESSION['admin'] == '1';
  }
  return false;
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <script type="text/javascript" src="js/jquery/jquery-1.7.min.js" ></script>
    <script type="text/javascript" src="js/jquery/jquery-bday-picker-1.2.min.js"></script>
    <script type="text/javascript" src="js/common.js" ></script>
    <script type="text/javascript" src="app/management/js" ></script>
    <script type="text/javascript" src="app/client/js" ></script>
    <script type="text/javascript" src="js/index.js"></script>
    <link rel="stylesheet" href="css/reset.css" />
    <link rel="stylesheet" href="css/common.css" />
    <link rel="stylesheet" href="css/index.css" />
    <link rel="shortcut icon" href="images/faveicon.ico" />
    <title >EPFMS</title>
  </head>
  <body>
    <div id="wrap">
      <header>
        <? if (isLogin()): ?>
          <div id="top-div">
            <span id="role">role: <strong><? echo isAdmin() ? 'god' : 'instructor'; ?></strong></span>
            <span id="username">username: <strong><? echo(isset($_SESSION['username']) ? $_SESSION['username'] : '?'); ?></strong></span>
          </div>
        <? endif ?>
        <div id="app-title">EPFMS</div>
        <div id="error-div"></div>
        <div id="notice-div"></div>
      </header>
      <? if (isLogin()): ?>
        <div id="sidebar-left">
          <div id="menu" >
            <? if (isAdmin()): ?>
              <a class="menu-item" id="instructors" href="javascript:void(0);">instructors</a>
            <? endif ?>
            <a class="menu-item" id="clients" href="javascript:void(0);">clients</a>
            <a class="menu-item" id="logout" href="javascript:void(0);" >logout</a>
          </div>
        </div>
        <div id="main-content">
        </div>
      <? else: ?>
        <form id="login-form">
          <div class="input-text"><label >username:</label><input name="username" type="text" /></div>
          <div class="input-text"><label >password:</label><input name="password" type="password" /></div>
          <input id="login-button" type="button" value="Login"/>
        </form>
      <? endif ?>
      <footer></footer>
    </div>
  </body>
</html>
